<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MealCompany extends Model
{
    protected $dateFormat = 'U';
    //
    protected $table = "lexiang_meal_company";

    protected $primaryKey = 'company_id';

    public function add($data)
    {
        $this_ = $this;
        $info = $this->where('admin_id',$data['admin_id'])->first();
        if($info){
            $this_ = $info;
        }
    	$this_->company_name = $data['name'];
    	$this_->admin_id = $data['admin_id'];
    	$this_->company_tel = $data['tel'];

    	if($this_->save()){
    		return [
    			'success'=>true,
    			'code'=>"000",
    			'message'=>'保存成功',
    			'data'=>[
    				'company_id'=>$this_->company_id
    			]
    		];
    	}else{
    		return [
    			'success'=>false,
    			'code'=>'006',
    			'message'=>"保存出错，请稍后再试！"
    		];
    	}
    }
}
